package TestModel;

import static org.junit.Assert.*;

import java.io.File;
import org.junit.Test;
import Task28.Command;
import Task28.Model;
import Task28.Result;

public class TestDelete {
	Model tester;
	Result result = new Result();
	Command command = new Command();

	public void init() {
		try {
			tester = new Model();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Test
	public void test1() {
		init();
		String[] args = { "C:\\TEST1\\test" };
		command.setNameCommand("delete");
		command.setArgs(args);

		try {
			result = tester.getResult(command);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		
		File test=new File(args[0]);
		assertFalse(test.exists());
	}
	
	@Test
	public void test2() {
		init();
		String[] args = { "C:\\TEST1\\test\\..\\test1" };
		command.setNameCommand("delete");
		command.setArgs(args);

		try {
			result = tester.getResult(command);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		
		File test=new File(args[0]);
		assertFalse(test.exists());
	}
	@Test
	public void test3() {
		init();
		String[] args = { "C:\\TEST1\\test2\\..\\test2" };
		command.setNameCommand("delete");
		command.setArgs(args);

		try {
			result = tester.getResult(command);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		
		File test=new File(args[0]);
		assertFalse(test.exists());
	}
}
